/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package DBFunction;

import org.json.JSONException;

import Constant.Constant;
import Json.LocationJson;
import Storage.Buddy;

public class fInsertLocation {
	public static void process(String LocationJsonString) throws JSONException {
		Buddy buddy = LocationJson.process(LocationJsonString);
		String phone = buddy.getPhoneNumber();
		String lat = buddy.getLatitude();
		String log = buddy.getLongitude();
		String lastupdate = Constant.getDateTime(); // changed
		//String lastupdate = buddy.getLastUpdate(); // changed
		String sql = "INSERT into buddytracking.position "
				+ "(UserId,Longitude,Latitude,LastUpdate) "
				+ "VALUES((select UserId from buddytracking.user WHERE PhoneNumber='"
				+ phone + "'),'" + log + "','" + lat + "','" + lastupdate
				+ "')";
		DB.connectDB.Update(sql);
	}
}
